package com.zhaoxi.project.wms.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.MesScheduleLine;
import com.zhaoxi.project.wms.service.impl.MesScheduleLineServiceImpl;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 计划排程Controller
 *
 * @author zhaoxi
 * @date 2023-11-10
 */
@RestController
@RequestMapping("/mes/scheduleLine")
public class MesScheduleLineController extends BaseService
{
    @Autowired
    private MesScheduleLineServiceImpl mesScheduleLineService;

    /**
     * 查询计划排程列表
     */
    @PreAuthorize("@ss.hasPermi('wms:scheduleLine:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesScheduleLine mesScheduleLine)
    {
        startPage();
        List<MesScheduleLine> list = mesScheduleLineService.selectMesScheduleLineList(mesScheduleLine);
        return getDataTable(list);
    }

    /**
     * 导出计划排程列表
     */
    @PreAuthorize("@ss.hasPermi('wms:scheduleLine:export')")
    @Log(title = "计划排程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesScheduleLine mesScheduleLine)
    {
        List<MesScheduleLine> list = mesScheduleLineService.selectMesScheduleLineList(mesScheduleLine);
        ExcelUtil<MesScheduleLine> util = new ExcelUtil<MesScheduleLine>(MesScheduleLine.class);
        util.exportExcel(response, list, "计划排程数据");
    }

    /**
     * 获取计划排程详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:scheduleLine:query')")
    @GetMapping(value = "/{lineId}")
    public PageData getInfo(@PathVariable("lineId") Long lineId)
    {
        return success(mesScheduleLineService.selectMesScheduleLineByLineId(lineId));
    }

    /**
     * 新增计划排程
     */
    @PreAuthorize("@ss.hasPermi('wms:scheduleLine:add')")
    @Log(title = "计划排程", businessType = BusinessType.INSERT)
    @PostMapping
    public PageData add(@RequestBody MesScheduleLine mesScheduleLine)
    {
        return toAjax(mesScheduleLineService.insertMesScheduleLine(mesScheduleLine));
    }

    /**
     * 修改计划排程
     */
    @PreAuthorize("@ss.hasPermi('wms:scheduleLine:edit')")
    @Log(title = "计划排程", businessType = BusinessType.UPDATE)
    @PutMapping
    public PageData edit(@RequestBody MesScheduleLine mesScheduleLine)
    {
        return toAjax(mesScheduleLineService.updateMesScheduleLine(mesScheduleLine));
    }

    /**
     * 删除计划排程
     */
    @PreAuthorize("@ss.hasPermi('wms:scheduleLine:remove')")
    @Log(title = "计划排程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lineIds}")
    public PageData remove(@PathVariable Long[] lineIds)
    {
        return toAjax(mesScheduleLineService.deleteMesScheduleLineByLineIds(lineIds));
    }
}
